package com.yunhe.inspect.task;

import com.yunhe.common.model.ResultObject;
import com.yunhe.inspect.service.SerialNumService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * @ClassName ResetSerialNumberTask
 * @Description TODO
 * @Author HeTao
 * @Date 2021/8/24 15:48
 * @Version 1.0
 **/
@Api(value = "ResetSerialNumberTask",description = "定时重置序列号",tags = "{ResetSerialNumber_Task}")
@RestController
@RequestMapping(value = "/publishTimed")
@Slf4j
public class ResetSerialNumberTask {

    @Autowired
    private SerialNumService serialNumService;

    @ApiOperation("定时发布")
    @RequestMapping(value ="/resetSerialNumber",method = RequestMethod.POST)
    @Scheduled(cron = "0 0 0 1/1 * ? ")
    @Async
    public ResultObject resetSerialNumber(){
        log.info("定时重置序列号定时任务开始");
        //定时发布事项
        serialNumService.resetSerialNumber();
        log.info("定时重置序列号定时任务结束");
        return new ResultObject<>(null);
    }
}
